﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Activation;
using Microsoft.SharePoint.Client.Services;
using MS.InformationManagement.DAL.DocumentCenter;
using System.ServiceModel;
using MS.InformationManagement.BLL.CaptureModule;
using MS.InformationManagement.BLL.CaptureOutcomeRadicado;

namespace MS.InformationManagement.Services
{
    [BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class ServiceCaptureProcess : IServiceCaptureProcess
    {
        public bool ProcessCapturedImage(int idSelectedItemToCapture, byte[] fileContent, string radicadoId, string siteUrl)
        {
            try
            {
                FileEntity fileContentEntity = new FileEntity();
                fileContentEntity.FileContent = fileContent;
                fileContentEntity.FileName = radicadoId+".tif";
                fileContentEntity.FileSize = fileContent.Length;
                CaptureProcess captureProcess = new CaptureProcess(idSelectedItemToCapture, fileContentEntity, siteUrl);
                captureProcess.Execute();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public bool ProcessCapturedOutComeImage(string uniqueRadicadoId, int documentId, string libraryName, byte[] fileContent)
        {
            try
            {
                FileEntity fileContentEntity = new FileEntity();
                fileContentEntity.FileContent = fileContent;
                fileContentEntity.FileName = uniqueRadicadoId + ".tif";
                fileContentEntity.FileSize = fileContent.Length;
                CaptureOutcomeProcess captureProcess = new CaptureOutcomeProcess(libraryName, documentId, fileContentEntity);
                captureProcess.Execute();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

    }
}
